<!DOCTYPE html>
<html>
  <head>
    <title>ArcGIS JS API Dojo Build Sample</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0 maximum-scale=1.0">
    <link rel="stylesheet" href="./../node_modules/arcgis-js-api/css/main.css">
    <style>
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }

      body {
        background-color: #FFF;
        overflow: hidden;
      }

      #banner {
        position: fixed;
        z-index: 999;
        top: 0;
        right: 0;
        padding: 2em;
        background-color: #EDA959;
        color: #fff;
        font-family: sans-serif;
      }

      #viewDiv {
        position: absolute;
        right: 0;
        left: 0;
        top: 0;
        bottom: 0;
      }

      #searchDiv {
        position: absolute;
        z-index: 20;
        top: 20px;
        left: 74px;
      }
    </style>
  </head>
  <body class="nihilo">
    <div id="banner">Unbuilt Application</div>
    <div id="searchDiv"></div>
    <div id="viewDiv"></div>

    <script>
    // create or use existing global dojoConfig
    var dojoConfig = this.dojoConfig || {};

    (function() {
      var config = dojoConfig;

      // set default properties
      if (!config.hasOwnProperty("async")) {
        config.async = true;
      }
      if (!config.hasOwnProperty("isDebug")) {
        config.isDebug = true;
      }

      // add packages for libs that are not siblings to dojo
      (function() {
        var packages = config.packages || [];

        function addPkgIfNotPresent(newPackage) {
          for (var i = 0; i < packages.length; i++) {
            var pkg = packages[i];
            if (pkg.name === newPackage.name) {
              return;
            }
          }

          packages.push(newPackage);
        }
        addPkgIfNotPresent({
          name: "app",
          location: "./../../src/app"
        });
        addPkgIfNotPresent({
          name: "esri",
          location: "../arcgis-js-api"
        });
        addPkgIfNotPresent({
          name: "@dojo",
          location: "../@dojo"
        });
        addPkgIfNotPresent({
          name: "dstore",
          location: "../dojo-dstore"
        });
        addPkgIfNotPresent({
          name: "cldrjs",
          location: "../cldrjs",
          main: "dist/cldr"
        });
        addPkgIfNotPresent({
          name: "globalize",
          location: "../globalize",
          main: "dist/globalize"
        });
        addPkgIfNotPresent({
          name: "maquette",
          location: "../maquette",
          main: "dist/maquette.umd"
        });
        addPkgIfNotPresent({
          name: "maquette-css-transitions",
          location: "../maquette-css-transitions",
          main: "dist/maquette-css-transitions.umd"
        });
        addPkgIfNotPresent({
          name: "maquette-jsx",
          location: "../maquette-jsx",
          main: "dist/maquette-jsx.umd"
        });
        addPkgIfNotPresent({
          name: "tslib",
          location: "../tslib",
          main: "tslib"
        });

        config.packages = packages;
      })();

      // configure map.globalize
      var map = config.map || {};
      if (!map.globalize) {
        map.globalize = {
          "cldr": "cldrjs/dist/cldr",
          "cldr/event": "cldrjs/dist/cldr/event",
          "cldr/supplemental": "cldrjs/dist/cldr/supplemental",
          "cldr/unresolved": "cldrjs/dist/cldr/unresolved"
        };
        config.map = map;
      }
    })();
    </script>
    <script src="../node_modules/dojo/dojo.js"></script>
    <script>require(["app/main"]);</script>

  </body>
</html>